From 06979e1dc429e57bf1e46c88dc8603efb26c06d2 Mon Sep 17 00:00:00 2001 From: Ewan Mellor Date: Tue, 20 Mar 2007 16:52:33 +0000 Subject: [PATCH] Have xm-test wait for the network device to detach. This is an asynchronous process, so xm-test needs to poll. Signed-off-by: Tom Wilkie --- .../tests/network-attach/network_utils.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tools/xm-test/tests/network-attach/network_utils.py b/tools/xm-test/tests/network-attach/network_utils.py index 084b5ebd90..93fe72a811 100644 --- a/tools/xm-test/tests/network-attach/network_utils.py +++ b/tools/xm-test/tests/network-attach/network_utils.py @@ -12,6 +12,18 @@ def count_eth(console): FAIL(str(e)) return len(run['output'].splitlines()) +def get_state(domain_name, number): + s, o = traceCommand("xm network-list %s | awk '/^%d/ {print $5}'" % + (domain_name, number)) + print o + + if s != 0: + FAIL("network-list failed") + if o == "": + return 0 + else: + return int(o) + def network_attach(domain_name, console): eths_before = count_eth(console) status, output = traceCommand("xm network-attach %s" % domain_name) @@ -30,6 +42,13 @@ def network_detach(domain_name, console, num=0): if status != 0: return -1, "xm network-detach returned invalid %i != 0" % status + for i in range(10): + if get_state(domain_name, num) == 0: + break + time.sleep(1) + else: + FAIL("network-detach failed: device did not disappear") + eths_after = count_eth(console) if eths_after != (eths_before-1): return -2, "Network device was not actually disconnected from domU" -- 2.30.2